var initForm = function(){
	$('#_form_default').form({
		url :'sys/GeneralUser/addOrUpdate',
		onBeforeLoad : function(param){
			$.messager.progress();
		},
		onLoadSuccess : function(data) {
			//加载完成之后才构建
			_set_select_selected(data);
			$.messager.progress("close");
		},
		onLoadError : function(data) {
			//加载完成之后才构建
			$.messager.progress("close");
			$.dialog.alert("加载内容失败,请重新刷新页面/联系管理员");
		},
		onSubmit : function(param) {
			if (!$(this).form("validate")) {
				$.dialog.alert("提交的选项中,有错误内容,请检查");
				return false;
			}
			$.messager.progress();
		},
		success : function(data) {	
			$.messager.progress("close");
			var jd = eval('(' + data + ')');
			if(!!!jd){
				$.dialog.alert("未知异常");
				return false;
			}
			if(jd.state!=200){
				$.dialog.alert(jd.message);
				return false;
			}
			//$.messager.alert('提示', '操作成功!',"info",function(){
			//	parent._do_goto_right(parent.basePath + 'jsp/client/client_subtle_list.jsp');
			//});
			
			$.dialog({
				icon: 'success.gif',
				title: '提示',
			    content: '操作成功！',
			    ok: function(){
			        this.close();
			    },
			    close: function(){
			    	parent._do_goto_right(parent.basePath + 'jsp/generalUser/list.jsp');
			    }
			});
			
		}
	});
};

var _to_valid_cardid = function(){
	
};

var fnDraw = function(url,picId){
	$('#picId').val(picId);
	$('#headPic').val(url);
	$('#showPic').attr('src',url);
	$('#showPic').css('display','block'); 
};

var init_select = function(){
	$('#sex').mSelect({
		myClass:'easyui-validatebox',
		width:240,
		baseCode:'Client_Sex_Code',
		//isAllSelect:false,
		dataOptions:'required:true'
	});
};



$(function(){
	//初始化表单
	initForm();
	//初始化下拉框
	init_select();
	if(typeof(_param_id)!='undefined' && _param_id.length > 0){
		$("#_form_default").form('load', 'sys/GeneralUser/findByPk?pks=' + _param_id);
	}
	$('input[name="confirm_button"]').click(function(){
		$('#_form_default').submit();
	});
	$('#fileUpload').click(function(){
		$.dialog({
			id:'headpicupload',
			title:'用户头像上传',
			lock:true,
			content:'url:jsp/file/accessory_upload.jsp',
			data:{'accessoryClass':1},
			width:700,
			height:600
		});
	});
	
});
